<?php
include_once 'php/connection.php';
session_start();
if(!isset($_SESSION['nenunnanu_admin']))
{
header("location:admin_login.php");
}
 include_once 'header.php'; 

if(isset($_GET['type'])&& $_GET['type']=='articles')
{
  $sql="select * from $_GET[type] order by id desc";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
  
 ?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Article title
</th>
<th>
Edit
</th>
<th>
Delete
</th>
</tr>
<?while($row=mysql_fetch_array($res)){ ?>
<tr>
<td>
<?=$row['title'] ?>
</td>
<td>
<a href="edit.php?id=<?=$row['id']?>&type=article"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=article"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?} ?>
</table>
<?}}
else if(isset($_GET['type'])&& $_GET['type']=='events'){
$sql="select * from events";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Event
</th>
<th>
Edit
</th>
<th>
Delete
</th>
</tr>
<?while($row=mysql_fetch_array($res)){
 ?>
<tr>
<td>
<?=$row['description'] ?>
</td>

<td>
<a href="edit.php?id=<?=$row['id']?>&type=event"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=event"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?} ?>
</table>
<?}}
else if(isset($_GET['type'])&& $_GET['type']=='quote')
{
  $sql="select * from quotes";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
  ?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Quote
</th>
<th>
Author
</th>
<th>
Edit
</th>
<th>
Delete
</th>

</tr>
<?while($row=mysql_fetch_array($res)){
 ?>
<tr>
<td>
<?=$row['quote'] ?>
</td>
<td>
<?=$row['author'] ?>
</td>

<td>
<a href="edit.php?id=<?=$row['id']?>&type=quote"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=quote"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>

<?}}}

else if(isset($_GET['type'])&& $_GET['type']=='events'){
$sql="select * from events";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Event
</th>
<th>
Edit
</th>
<th>
Delete
</th>
</tr>
<?while($row=mysql_fetch_array($res)){
 ?>
<tr>
<td>
<?=$row['description'] ?>
</td>

<td>
<a href="edit.php?id=<?=$row['id']?>&type=event"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=event"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?} ?>
</table>
<?}}
else if(isset($_GET['type'])&& $_GET['type']=='speak')
{
  $sql="select * from donor_speak";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
  ?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Donor Speak
</th>
<th>
Donor Name
</th>
<th>
Edit
</th>
<th>
Delete
</th>

</tr>
<?while($row=mysql_fetch_array($res)){
 ?>
<tr>
<td>
<?=$row['speak'] ?>
</td>
<td>
<?=$row['donor_name'] ?>
</td>

<td>
<a href="edit.php?id=<?=$row['id']?>&type=speak"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=speak"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?}}
}
else if(isset($_GET['type'])&& $_GET['type']=='faq')
{
  $sql="select * from faq";
  if(!$res=mysql_query($sql))
  {
  echo mysql_error();
  }
  else
  {
  ?>
<table align="center" width="90%" id="tableadmin">
<tr>
<th width="35%">
Question
</th>
<th width="55%">
Answer
</th>
<th>
Edit
</th>
<th>
Delete
</th>

</tr>
<?while($row=mysql_fetch_array($res)){
 ?>
<tr>
<td>
<?=stripslashes($row['question']) ?>
</td>
<td>
<?=stripslashes($row['answer']) ?>
</td>

<td>
<a href="edit.php?id=<?=$row['id']?>&type=faq"><img
			src="assets/imgs/edit.png" border='0' /></a>
</td>
<td>
<a href="delete.php?id=<?=$row['id']?>&type=faq"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?}}} ?>

</table>

</table>
  

</body>
</html>